package com.auto.sns.core.action;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.auto.sns.core.domain.SnsCoreActivity;
import com.auto.sns.core.domain.SnsCoreHyperlink;
import com.auto.sns.core.domain.SnsCoreTopic;
import com.auto.sns.core.domain.SnsCoreVote;
import com.auto.sns.core.service.SnsCoreServiceFactory;
import com.auto.sns.core.util.CoreUtil;
import com.auto.tools.AutoUtils;
import com.system.common.BaseAction;
import com.system.common.Page;
import com.system.util.BeanUtil;

/**
 * 动态中心action
 * @author wsh
 *
 */
public class SnsCoreMyDynamicCenterAction extends BaseAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 7526392449207008209L;
	
	/**
	 * 获取我的动态
	 */
	public String getMyDynamicInfo(){
		try {
			Page page = null;
			if(BeanUtil.isBlank(getRequest().getParameter("pageIndex"))){
				page = new Page(1, 10);
			}else{
				page = getPage();
			}
			
			String userCode = AutoUtils.getUserCode();
			
			//全部类型
			List allList = new ArrayList();
			
			
			this.getRequest().setAttribute("checktype", "myDynamic");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "success";
	}
	
	/**
	 * 获取我的动态之活动
	 */
	public String getMyDynamicActivityInfo(){
		try {
			Page page = null;
			if(BeanUtil.isBlank(getRequest().getParameter("pageIndex"))){
				page = new Page(1, 10);
			}else{
				page = getPage();
			}
			
			String userCode = AutoUtils.getUserCode();
			
			
			//活动类型
			SnsCoreActivity snsCoreActivity = new SnsCoreActivity();
			snsCoreActivity.setPubUserName(userCode);
			
			List<SnsCoreActivity> activityList = SnsCoreServiceFactory.snsCoreInfoService.queryPageListSnsCoreActivity(snsCoreActivity, page);
			
			this.getRequest().setAttribute("activityList", activityList);
			this.getRequest().setAttribute("checktype", "myDynamic");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "success";
	}
	/**
	 * 获取我的动态之投票
	 */
	public String getMyDynamicVoteInfo(){
		try {
			Page page = null;
			if(BeanUtil.isBlank(getRequest().getParameter("pageIndex"))){
				page = new Page(1, 10);
			}else{
				page = getPage();
			}
			
			String userCode = AutoUtils.getUserCode();
			
			SnsCoreVote snsCoreVote = new SnsCoreVote();
			snsCoreVote.setPubUserName(userCode);
			
			List<SnsCoreVote> voteList = SnsCoreServiceFactory.snsCoreInfoService.queryPageListSnsCoreVote(snsCoreVote, page);

			this.getRequest().setAttribute("voteList", voteList);
			this.getRequest().setAttribute("checktype", "myDynamic");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return "success";
	}
	/**
	 * 获取我的动态之话题
	 */
	public String getMyDynamicTopicInfo(){
		try {
			Page page = null;
			if(BeanUtil.isBlank(getRequest().getParameter("pageIndex"))){
				page = new Page(1, 10);
			}else{
				page = getPage();
			}
			
			String userCode = AutoUtils.getUserCode();
			
			
			//活动类型
			SnsCoreTopic snsCoreTopic = new SnsCoreTopic();
			snsCoreTopic.setPubUserName(userCode);
			
			List<SnsCoreTopic> topicList = SnsCoreServiceFactory.snsCoreInfoService.queryPageListSnsCoreTopic(snsCoreTopic, page);

			this.getRequest().setAttribute("topicList", topicList);
			this.getRequest().setAttribute("checktype", "myDynamic");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return "success";
	}
	
	/**
	 * 获取我的动态之连接
	 */
	public String getMyDynamicHyperlinkInfo(){
		try {
			Page page = null;
			if(BeanUtil.isBlank(getRequest().getParameter("pageIndex"))){
				page = new Page(1, 10);
			}else{
				page = getPage();
			}
			
			String userCode = AutoUtils.getUserCode();
			
			SnsCoreHyperlink snsCoreHyperlink = new SnsCoreHyperlink();
			snsCoreHyperlink.setPubUserName(userCode);
			
			List<SnsCoreHyperlink> hyperlinkList = SnsCoreServiceFactory.snsCoreInfoService.queryPageListSnsCoreHyperlink(snsCoreHyperlink, page);

			
			this.getRequest().setAttribute("hyperlinkList", hyperlinkList);
			this.getRequest().setAttribute("checktype", "myDynamic");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return "success";
	}
	
	/**
	 * 获取我的动态之消息
	 */
	public String getMyDynamicMessageInfo(){
		try {
			Page page = null;
			if(BeanUtil.isBlank(getRequest().getParameter("pageIndex"))){
				page = new Page(1, 10);
			}else{
				page = getPage();
			}
			
			String userCode = AutoUtils.getUserCode();
			
			
			//活动类型
//			SnsCoreMessage snsCoreMessage = new SnsCoreMessage();
//			snsCoreMessage.setPubUserName(userCode);
//			
//			List<SnsCoreMessage> messageList = SnsCoreServiceFactory.snsCoreInfoService.queryPageListSnsCoreMessage(snsCoreMessage, page);
//			
//			this.getRequest().setAttribute("activityList", messageList);
			this.getRequest().setAttribute("checktype", "myDynamic");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return "success";
	}

}
